<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="csrf-token" content="{{ csrf_token() }}">
  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"></script>
  <script src="{{ url_for('static',filename='common/zlajax.js') }}"></script>
  <title>{% block title %}{% endblock %}</title>
  <link rel="stylesheet" href="{{ url_for('static',filename='cms/css/base.css') }}">
  {% block head %}{% endblock %}
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
  <a class="navbar-brand" href="#">知了CMS管理系统</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav ml-auto">
      <li class="nav-item">
        <a href="{{ url_for('user.profile',user_id=g.user.id) }}" class="nav-link">{{ g.user.username }}</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="/">前台首页</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="{{ url_for('user.logout') }}">退出登录</a>
      </li>
    </ul>
  </div>
</nav>

<div class="main-body">
  <div class="left-body">
    <div class="sidebar">
      <ul class="nav-sidebar">
        <li class="unfold"><a href="{{ url_for('cms.index') }}">首页</a></li>
        {% set user = g.user %}
        {% if user.has_permission(PermissionEnum.POST) %}
          <li class="nav-group post-manage"><a href="{{ url_for('cms.post_list') }}">帖子管理</a></li>
        {% endif %}
        {% if user.has_permission(PermissionEnum.COMMENT) %}
          <li class="comments-manage"><a href="{{ url_for('cms.comment_list') }}">评论管理</a></li>
        {% endif %}
        {% if user.has_permission(PermissionEnum.BOARD) %}
          <li class="board-manage"><a href="{{ url_for('cms.board_list') }}">板块管理</a></li>
        {% endif %}
        {% if user.has_permission(PermissionEnum.FRONT_USER) %}
          <li class="nav-group user-manage"><a href="{{ url_for('cms.user_list') }}">用户管理</a></li>
        {% endif %}
        {% if user.has_permission(PermissionEnum.CMS_USER) %}
          <li class="nav-group UserModel-manage"><a href="{{ url_for('cms.staff_list') }}">员工管理</a></li>
        {% endif %}
      </ul>
    </div>
  </div>
  <div class="right-body">
    <div class="main">
      <h1>{% block page_title %}{% endblock %}</h1>
      <div class="main_content">
        {% block main_content %}{% endblock %}
      </div>
    </div>
  </div>
</div>
</body>
</html>